package com.oedtech.esl.repository.esl;

import com.oedtech.esl.model.esl.Ap;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.beans.Transient;

/**
 * @Author QiuLongYu
 * @Date 2019/7/30
 * 基站dao
 */
public interface ApDao extends JpaSpecificationExecutor<Ap>,JpaRepository<Ap,String> {

    @Query(value = "select ap_id from ap where mac=?1 limit 1",nativeQuery = true)
    String findApIdByMac(String mac);


    @Transactional
    @Modifying
    @Query(value = "update ap set status='offline',last_work_time=now() where ap_id=?1",nativeQuery = true)
    int apOffline(String apId);

    @Transactional
    @Modifying
    @Query(value = "update ap set channel=?1 where ap_id=?2",nativeQuery = true)
    int updateChannel(String channel,String apid);

    @Transactional
    @Modifying
    @Query(value = "update ap set status='offline'",nativeQuery = true)
    void restStatus();
}



